package com.dongnam.quanly.ChiTietPhieuNhapXuat;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class aaa {

	public static void main(String[] args) throws SQLException, ClassNotFoundException {
		String userName ="sa";
		String password ="sqlserver123";
		String url ="jdbc:jtds:sqlserver://localhost/CLXD";
		Class.forName("net.sourceforge.jtds.jdbc.Driver");
		Connection conn = DriverManager.getConnection(url, userName, password);
		try{           

		    PreparedStatement ps = conn.prepareStatement("select top 20(so_hoadon),ma_k_hang,makho,ngay from hoadonkhac");
		    /* if UDF, and need to pass params, can do something like:
		    ...prepareStatement("select * from UDF('" + UDFinputVal + "')" */

		    ResultSet rs = ps.executeQuery();

		    while (rs.next()) {

				       
				        String shortestDistance = rs.getString(4);
				        System.out.println(shortestDistance);

		    }  

		    rs.close();
		    ps.close();            
		}
		catch (Exception e) {
		    e.printStackTrace();
		}
	}

}
